/**
 *
 */
;
//存储报警信息，判断目前是否还存在报警，来确定是否播放警铃
var alarmMap = new Map();
var loginNmae = "";

//状态转换
function getStatusStr(status) {
    var statusStr = 'normal';
    switch (status) {
        case 1:
            statusStr = "fire";  //火警
            break;
        case 2:
            statusStr = "normal"; //静音
            break;
        case 3:
            statusStr = "malfunction"; //故障
            break;
        case 4:
            statusStr = "lowpower"; //低压
            break;
        case 7:
            statusStr = "normal"; //正常待机
            break;
        case 9:
            statusStr = "normal"; //自检数据上报
            break;


        default:
            break;
    }
    return statusStr;
}

var devCodeArray = [];
$.ajax({
    url: '/deviceStatus/byuser',
    type: 'get',
    success: function (result) {
        if (result.status == 200) {
            for (var i = 0; i < result.data.length; i++) {
                var devCode = result.data[i].devCode;
                devCodeArray.push(devCode);
            }
        } else {
            winTip.alert(result.message)
        }
    }
});
//将设备编号存到数组
//var devCodeArray = [];devCodeArray.push(r.device.devCode);
//获取 烟感 设备数据并渲染
function renderSmoke() {
    //获取设备状态列表，并在地图上更新   (普通模式)
    $.ajax({
        url: "/deviceStatus/data/list/bydevicetype/001/byuser",
        type: "GET",
        //async: false,
        success: function (result) {
            if (result.status == "200") {
            	console.log(result)

                for (var ri = 0; ri < result.data.length; ri++) {
                	
                    var r = result.data[ri];
                    if (r.status == 1) {
                        alarmMap.set(r.device.devCode, r.status);
                    }

            	    //console.log(BaiDuMap.deletePoint(),r.device.devCode)
                    BaiDuMap.deletePoint(r.device.devCode);
                    BaiDuMap.addDot(r.device.latitude, r.device.longitude, r.device.devCode, r.device.deviceName, r.device.address, getStatusStr(r.status), r.device.linkMain1, r.device.linkPhone1, r.device.linkMain2, r.device.linkPhone2, r.device.linkMain3, r.device.linkPhone3, r.device.linkMain4, r.device.linkPhone4,r.fireCount);

                }
                toggleFlag = null;
            } else {
            	
            }
        }
    });
}


//摄像头
function renderCamera() {
    //获取设备状态列表，并在地图上更新   (普通模式)
    $.ajax({
        url: '/deviceStatus/data/list/bydevicetype/003/byuser',
        type: 'get',
        //async: false,
        success: function (result) {
            if (result.status == 200) {
                for (var ri = 0; ri < result.data.length; ri++) {
                    var r = result.data[ri];
                    if (r.status == 1) {
                        alarmMap.set(r.device.devCode, r.status);
                    }
                    BaiDuMap.deletePoint(r.device.devCode);
                    BaiDuMap.cameraAddDot(r.device.latitude, r.device.longitude, r.device.devCode, r.device.deviceName, r.device.address, "cameraNormal", r.device.linkMain1, r.device.linkPhone1, r.device.linkMain2, r.device.linkPhone2, r.device.linkMain3, r.device.linkPhone3, r.device.linkMain4, r.device.linkPhone4, r.device.cameraUrl, r.device.cameraUser, r.device.cameraPassowrd);

                }
            } else {
                winTip.alert(result.message)
            }
        }
    });
}

//路灯
function renderStreetLamp() {
    $.ajax({
        url: '/deviceStatus/data/list/bydevicetype/004/byuser',
        type: 'get',
        //async: false,
        success: function (result) {
            if (result.status == 200) {
                for (var ri = 0; ri < result.data.length; ri++) {
                    var r = result.data[ri];
                    var streetstatus = 'streetLampOff';
                    //20->1号   21->2号 24关   20->开
                    if (r.status == 20) {
                        streetstatus = 'streetLampOn';
                    } else if (r.status == 24) {
                        streetstatus = 'streetLampOff';
                    }else{
                    	streetstatus = 'streetLampOff';
                    }
                    BaiDuMap.deletePoint(r.device.devCode);
                    BaiDuMap.streetLampAddDot(r.device.latitude, r.device.longitude, r.device.devCode, r.device.deviceName, r.device.address, streetstatus, r.device.linkMain1, r.device.linkPhone1, r.device.linkMain2, r.device.linkPhone2, r.device.linkMain3, r.device.linkPhone3, r.device.linkMain4, r.device.linkPhone4);

                }
            } else {
                winTip.alert(result.message)
            }
        }
    });


}
function renderManholeCover() {
    $.ajax({
        url: '/deviceStatus/data/list/bydevicetype/005/byuser',
        type: 'get',
        //async: false,
        success: function (result) {
        	console.log(result)
            if (result.status == 200) {
                for (var ri = 0; ri < result.data.length; ri++) {
                    var r = result.data[ri];
                    var coverStatus = null;
                    //10->异位 	11—>正常	  12->低电 	 14->故障
                    if (r.status == 10) {
                        coverStatus = 'manholeCoverEctopic';
                    } else if (r.status == 14) {
                        coverStatus = 'manholeCoverFault';
                    } else if (r.status == 12) {
                        coverStatus = 'manholeCoverLow';
                    } else if (r.status == 11) {
                        coverStatus = 'manholeCoverNormal';
                    }else{
                    	coverStatus = 'manholeCoverNormal';
                    }
                    BaiDuMap.deletePoint(r.device.devCode);
                    BaiDuMap.manholeCoverAddDot(r.device.latitude, r.device.longitude, r.device.devCode, r.device.deviceName, r.device.address, coverStatus, r.device.linkMain1, r.device.linkPhone1, r.device.linkMain2, r.device.linkPhone2, r.device.linkMain3, r.device.linkPhone3, r.device.linkMain4, r.device.linkPhone4);

                }
            } else {
                winTip.alert(result.message)
            }
        }
    });
}
function renderHumiture() {
//	BaiDuMap.humitureAddDot("120.1758834947", "30.2472521529", "1", "温湿度", "hjii", 'humitureNormal');

    $.ajax({
        url: '/deviceStatus/data/list/bydevicetype/007/byuser',
        type: 'get',
        //async: false,
        success: function (result) {
            if (result.status == 200) {
                for (var ri = 0; ri < result.data.length; ri++) {
                    var r = result.data[ri];
                    var humitureStatus = null;
                    // 
                    if (r.status == 61) {
                        humitureStatus = 'humitureAlarm';
                    } else if (r.status == 60) {
                        humitureStatus = 'humitureNormal';
                    } else if (r.status == 62) {
                        humitureStatus = 'humitureFault';
                    }else{
                    	humitureStatus = 'humitureNormal';
                    }
                    var humidity = r.humidity ? r.humidity + "%" : "";
                    var temperature1 = r.temperature1 ? r.temperature1 + '℃&nbsp;' : "";

                    BaiDuMap.deletePoint(r.device.devCode);
                    BaiDuMap.humitureAddDot(r.device.latitude, r.device.longitude, r.device.devCode, r.device.deviceName, r.device.address, humitureStatus, r.device.linkMain1, r.device.linkPhone1, r.device.linkMain2, r.device.linkPhone2, r.device.linkMain3, r.device.linkPhone3, r.device.linkMain4, r.device.linkPhone4, temperature1, humidity);

                }
            } else {
                winTip.alert(result.message)
            }
        }
    });
}
function renderTrash() {
    $.ajax({
        url: '/deviceStatus/data/list/bydevicetype/006/byuser',
        type: 'get',
        //async: false,
        success: function (result) {
            if (result.status == 200) {
                for (var ri = 0; ri < result.data.length; ri++) {
                    var r = result.data[ri];
                    var trashStatus = null;
                    //31->溢出 	30—>正常	  32->高温 	33->倾倒	 34->故障
                    if (r.status == 31) {
                        trashStatus = 'trashBrimOver';
                    } else if (r.status == 34) {
                        trashStatus = 'trashFault';
                    } else if (r.status == 32) {
                        trashStatus = 'trashHighTemp';
                    } else if (r.status == 33) {
                        trashStatus = 'trashDump';
                    } else if (r.status == 30) {
                        trashStatus = 'trashNormal';
                    } else {
                    	trashStatus = 'trashNormal';
                    }
                    BaiDuMap.deletePoint(r.device.devCode);
                    BaiDuMap.trashAddDot(r.device.latitude, r.device.longitude, r.device.devCode, r.device.deviceName, r.device.address, trashStatus, r.device.linkMain1, r.device.linkPhone1, r.device.linkMain2, r.device.linkPhone2, r.device.linkMain3, r.device.linkPhone3, r.device.linkMain4, r.device.linkPhone4);
                }
            } else {
                winTip.alert(result.message)
            }
        }
    });
}
//str.substring(1,str.length)
	function setAnyChartFun(data1,data2,data3) {
        var myChart1 = echarts.init(document.getElementById('myChart1'));
        var MM = moment().add('days',0).format('MM');
        var DD = moment().add('days',0).format('DD');
        if(MM.length>1&&MM.substring(0,1)=="0"){
        	MM = MM.substring(1,2)
        }
        if(DD.length>1&&DD.substring(0,1)=="0"){
        	DD = DD.substring(1,2)
        }
        option = {
//            title: {
//                text: "温湿度折线图",//MM+"月"+DD+'日温湿度变化'
//                //top:-20,
//                textStyle:{
//                	fontSize:14,
//                }
//                //subtext: '纯属虚构'
//            },
            animation: false,
            tooltip: {
                trigger: 'axis'
            },
            legend: {
                data: [ {name:'湿度（%）',icon:'rect',},{name:'温度（℃）',icon:'rect'}],//image://./icons/fire-alarm-tab.png
                right: '0%',
                //selectedMode: 'single',//控制只显示一条折线
            },
            grid: {
                left: '3%',
                right: '3%',
                bottom: '3%',
                containLabel: true
            },
//            dataZoom: [
//                {
//                    show: true,
//                    realtime: true,
////                    start: 99.9,
////                    end: 100
//                },
//                {
//                    type: 'inside',
//                    realtime: true,
//                    //start: 65,
//                    //end: 85
//                }
//            ],
            xAxis: {
                type: 'category',
                boundaryGap: false,
                data: data3
            },
            //yAxis: {
            //    type: 'value',
            //    axisLabel: {
            //        formatter: '{value} °C'
            //    }
            //},
            yAxis: [{
                type: 'value',
                name: '温度（℃）',
                position: 'left',
                min: 0,
                max: 100,
                axisLabel: {
                    formatter: '{value} '
                }
            }, {
                type: 'value',
                name: '湿度（%）',
                min: 0,
                max: 100,
                position: 'right',
                axisLabel: {
                    formatter: '{value} '
                }
            },],
            series: [{
                name: '温度（℃）',
                type: 'line',
                symbolSize: 2,//拐点大小
                smooth: true,
                barWidth: '20%',
                yAxis: 1,
                itemStyle: {
                    normal: {
                        color: 'red',
                        width: 1,//折线宽度
                    },
                    
                },
                lineStyle: {
                    width: 1 //default value:2
                },
                data: data1,
                markLine: {
                    silent: true,
                    data: [{
                        yAxis: 50,
                    },],
                    label:{show:true,position:'left',formatter: '',}
                }
                
                
                
            }, {
                name: '湿度（%）',
                type: 'line',
                smooth: true,
                symbolSize: 2,//拐点大小
                yAxisIndex: 1,
                itemStyle: {
                    normal: {
                        color: 'green',
                        width: 1,//折线宽度
                    }
                },
                lineStyle: {
                    width: 1 //default value:2
                },
                data: data2,
                markLine: {
                    silent: true,
                    data: [{
                        yAxis: 60
                    },],

                    label:{show:true,position:'left',formatter: '',}
                }
            },
            ]
        };
        // 使用刚指定的配置项和数据显示图表。
        myChart1.setOption(option);
    }
function layoutIni() {
    //获取当前登录用户信息
    getCurrentUser();
    //初始化地图，获取当前组织经纬度
    BaiDuMap.initialize(topOrgCentrex, topOrgCentrey, 15);


    //获取设备列表，并在地图上画出
//      $.ajax({
//        url:"/device/data/list",
//        type:"GET",
//        async:false,
//        success:function(result){
//          if(result.status=="200"){
//            for(var ri in result.data) {
//            	
//              var r = result.data[ri];
//              BaiDuMap.addDot(r.latitude,r.longitude,r.devCode,r.deviceName,r.address,'normal',r.linkMain1,r.linkPhone1,r.linkMain2,r.linkPhone2,r.linkMain3,r.linkPhone3,r.linkMain4,r.linkPhone4);
//            }
//            
//          } else {
//		  	
//          }
//        }
//
//      })

    renderSmoke();



    //建立websocket
    var websocket = null;

    //鍒ゆ柇褰撳墠娴忚鍣ㄦ槸鍚︽敮鎸乄ebSocket
    if ('WebSocket' in window) {
        var webhost = location.hostname.toLowerCase();
//        http 协议
        if(webhost.indexOf("com")>=0){
        	websocket = new WebSocket("ws://47.96.179.13:9090/websocket/signalmonitor/"+loginNmae);
        } else {
        	websocket = new WebSocket("ws://" + webhost + ":9090/websocket/signalmonitor/" + loginNmae);
        }
       
//        https 协议
//        if(webhost.indexOf("com")>=0){
//        	websocket = new WebSocket("wss://47.96.179.13:443/websocket/signalmonitor/"+loginNmae);
//        } else {
//        	websocket = new WebSocket("wss://" + webhost + ":443/websocket/signalmonitor/" + loginNmae);
//        }
        
    }
    else {
        winTip.alert('Not support websocket')
    }

    //杩炴帴鍙戠敓閿欒鐨勫洖璋冩柟娉�
    websocket.onerror = function () {
        console.log("error");
    };

    //杩炴帴鎴愬姛寤虹珛鐨勫洖璋冩柟娉�
    websocket.onopen = function (event) {
    	console.log("open");
    }

    //鎺ユ敹鍒版秷鎭殑鍥炶皟鏂规硶
    websocket.onmessage = function (event) {
    	console.log(event)
        //setMessageInnerHTML(event.data);
        var str = event.data;
        var strs = str.split(",");
        //数组第一个为命令字，用于判断是什么业务
        var cmd = strs[0];
        //var websocketDevType = $(".bottombar").attr("devType");
        //接收到报警信息
        if (cmd == "cmd_sendAlarm") {
            if (strs.length >= 8) {
                var devCode = strs[1];
                var status = strs[2];
                var statusStr = strs[3];
                var Latitude = strs[4];
                var Longitude = strs[5];
                var deviceName = strs[6];
                var address = strs[7];
                var returntime = strs[8];
                var linkMain1 = strs[9];
                var linkPhone1 = strs[10];
                var linkMain2 = strs[11];
                var linkPhone2 = strs[12];
                var linkMain3 = strs[13];
                var linkPhone3 = strs[14];
                var linkMain4 = strs[15];
                var linkPhone4 = strs[16];
                var alarmId = strs[17];

                if (strs[18]) {
                    var humitureNum = strs[18] + '℃&nbsp;';
                } else {
                    var humitureNum = "";
                    //$(".humitureNum").removeClass("humitureNumA");
                }
                if (strs[19]) {
                    var temperatureNum = strs[19] + "%";
                } else {
                    var temperatureNum = "";
                }

                console.log("传进的报警状态：" + status);
                //判断websocket传进来的报警信息是否是当前的用户
                var devCodeFlag = false;
                for (var i = 0; i < devCodeArray.length; i++) {
                    if (devCode == devCodeArray[i]) {
                        devCodeFlag = true;
                    }
                }
                if (devCodeFlag) {
                    //烟感火警报警
                    if (status == 1) {
                    	var dataSumAlarm = +$(".dataSumAlarm").text()+1;
                    	$(".dataSumAlarm").text(dataSumAlarm)
                    	//dataSumAlarmFunc();
                        //弹出报警窗口
                        alertWarningInitTime(deviceName, address, linkMain1, linkMain2, linkMain3, linkMain4, linkPhone1, linkPhone2, linkPhone3, linkPhone4, devCode, alarmId, returntime)

                        smokeTipAlarmFunc();
                    }
                    if (status == 1 || status == 3 || status == 4 || status == 7) {
                        alarmInfo(deviceName, address, returntime, Latitude, Longitude, devCode, status);
                        historyInfo(deviceName, address, returntime, Latitude, Longitude, devCode, status);
                    } else if (status == 10 || status == 12 || status == 13 || status == 14) {
                        $('.manholeCoverHeader .historyBgc .historyMsg').attr("id", "coverTwinkle");
                        $('.manholeCoverHeader .historyBgc').on('click', function () {
                            $('.manholeCoverHeader .historyBgc .historyMsg').removeAttr("id", "coverTwinkle");
                        });
                        coverHistoryInfo(deviceName, address, returntime, Latitude, Longitude, devCode, status);
                    } else if (status == 60 || status == 61 || status == 62) {
                        $('.humitureHeader .historyBgc .historyMsg').attr("id", "humitureTwinkle");
                        $('.humitureHeader .historyBgc').on('click', function () {
                            $('.humitureHeader .historyBgc .historyMsg').removeAttr("id", "humitureTwinkle");
                        });
                        coverHistoryInfo(deviceName, address, returntime, Latitude, Longitude, devCode, status);
                    }
                    if (devType == "smokeDetector") {
                        if (status == 1) {
                        	
                            playSound();
                            speach('警报：' + address + deviceName + '烟雾报警');

                            /*实时添加重点关注对象数量*/
                            focusNumFun(devCode);
                            /* 获取实时的柱状图报警信息 */
                            alarmTime1(moment().add('days', 0).format('YYYY-MM-DD'), "001", "001")
                            //alarmTime(moment().add('days', 0).format('YYYY-MM-DD'),"001","001");

                            alarmMap.set(devCode, status);
                            //大数据重点关注
                           // dataGuanZhuTIme1(devCode)
                        } else {
                            alarmMap.delete(devCode);
                            if (alarmMap.size == 0) {
                                stopSound();
                            }
                        }
                        if (status == 1 || status == 3 || status == 4 || status == 7) {
                            BaiDuMap.deletePoint(devCode);
                            BaiDuMap.addDot(Latitude, Longitude, devCode, deviceName, address, statusStr, linkMain1, linkPhone1, linkMain2, linkPhone2, linkMain3, linkPhone3, linkMain4, linkPhone4);

                        }
                    } else if (devType != "smokeDetector") {
                        //隐藏报警弹出框
                        $(".alertWarningContent").hide();
                    }

                    //井盖异位报警
                    if (status == 10) {
//    	        	  设备未切换成井盖
                        //井盖时，设备切换按钮显示报警条数
                        $("#manholeCoverBtn .tip-alarm").show();
                        manholeCoverWarningInitTime(deviceName, address, linkMain1, linkMain2, linkMain3, linkMain4, linkPhone1, linkPhone2, linkPhone3, linkPhone4, devCode, alarmId, returntime);
                        $("#manholeCoverBtn .tip-alarm").text(coverMaxWarningSum);
                    }

                    if (devType == "manholeCover") {
                        var coverStatus = null;
                        if (status == 10) {
                            playSound();
                            speach('警报：' + address + deviceName + '窨井盖异位报警');
                            /*实时添加重点关注对象数量*/
                            focusNumFun(devCode);
                            alarmTime1(moment().add('days', 0).format('YYYY-MM-DD'), "005", "010");
                            alarmMap.set(devCode, status);
                        } else {
                            alarmMap.delete(devCode);
                            if (alarmMap.size == 0) {
                                stopSound();
                            }
                        }
                        //10->异位 	11—>正常	  12->低电 	 14->故障
                        if (status == 10) {
                            coverStatus = 'manholeCoverEctopic';
                            //manholeCoverWarningInitTime(deviceName, address, linkMain1, linkMain2, linkMain3, linkMain4, linkPhone1, linkPhone2, linkPhone3, linkPhone4, devCode, alarmId, returntime);
                        } else if (status == 14) {
                            coverStatus = 'manholeCoverFault';
                        } else if (status == 12) {
                            coverStatus = 'manholeCoverLow';
                        } else if (status == 11) {
                            coverStatus = 'manholeCoverNormal';
                        }
                        if (status == 10 || status == 11 || status == 12 || status == 14) {
                            BaiDuMap.deletePoint(devCode);
                            BaiDuMap.manholeCoverAddDot(Latitude, Longitude, devCode, deviceName, address, coverStatus, linkMain1, linkPhone1, linkMain2, linkPhone2, linkMain3, linkPhone3, linkMain4, linkPhone4);
                            coverNumFunc();
                        }

                    } else if (devType != "manholeCover") {
                        $(".manholeCoverWarningContent").hide();
                    }
                    //-------------
                    //温湿度报警	60->正常	61->报警	62->故障
//                    if(status == 60||status == 61||status == 62){
//                    	BaiDuMap.deletePoint(devCode);
//                        BaiDuMap.humitureAddDot(Latitude, Longitude, devCode, deviceName, address, statusStr, linkMain1, linkPhone1, linkMain2, linkPhone2, linkMain3, linkPhone3, linkMain4, linkPhone4,temperatureStatus,humitureStatus);
//                        
//                    }
                    if (status == 61) {
//    	        	  设备未切换成井盖
                        //井盖时，设备切换按钮显示报警条数
                        $("#humitureBtn .tip-alarm").show();
                        humitureWarningInitTime(deviceName, address, linkMain1, linkMain2, linkMain3, linkMain4, linkPhone1, linkPhone2, linkPhone3, linkPhone4, devCode, alarmId, returntime);
                        $("#humitureBtn .tip-alarm").text(humitureMaxWarningSum);
                    }

                    if (devType == "humiture") {
                        var humitureStatus = null;
                        if (status == 61) {
                            playSound();
                            speach('警报：' + address + deviceName + '温湿度报警');
                            /*实时添加重点关注对象数量*/
                            focusNumFun(devCode);
                            alarmTime1(moment().add('days', 0).format('YYYY-MM-DD'), "007", "061");
                            alarmMap.set(devCode, status);
                        } else {
                            alarmMap.delete(devCode);
                            if (alarmMap.size == 0) {
                                stopSound();
                            }
                        }
                        if (status == 61) {
                            humitureStatus = 'humitureAlarm';
                            //----------
                            var data1 = [];
                            var data2 = [];
                            var data3 = [];
                    	       var beginTime = moment().add('days',-1).format('YYYY-MM-DD')+" 00:00:00";
                    	       var endTime = moment().add('days',0).format('YYYY-MM-DD')+" 23:59:59";
                           var humidity="";
                           var temperature1="";
                            $.ajax({
                                type: "GET",
                                url: "/deviceStatusHistory/listByTimeAndCode/sorting?beginTime="+beginTime+"&endTime="+endTime+"&devCode=" + devCode,
                                async: false, //同步执行
                                dataType: "json", //返回数据形式为json result.data.length
                                success: function (result) {
                                    if (result.status == 200) {
                                        for (var i = 0; i < result.data.length; i++) {
                                        	temperature1 = result.data[i][0] ? result.data[i][0] : "";
                                        	humidity = result.data[i][1] ? result.data[i][1] : "";
                                            data2.push(humidity)
                                            data1.push(temperature1);
                                            data3.push(moment(result.data[i][2]).format('HH:mm'));
                                        }
                                    }
                                },
                                error: function (errorMsg) {
                                    winTip.alert("请求数据失败!");
                                    myChart.hideLoading();
                                }
                            });
                            setAnyChartFun(data1,data2,data3);
                            //----------
                        } else if (status == 62) {
                            humitureStatus = 'humitureFault';
                        } else if (status == 60) {
                            humitureStatus = 'humitureNormal';
                        }
                        if (status == 60 || status == 61 || status == 62) {
                            BaiDuMap.deletePoint(devCode);
                            BaiDuMap.humitureAddDot(Latitude, Longitude, devCode, deviceName, address, humitureStatus, linkMain1, linkPhone1, linkMain2, linkPhone2, linkMain3, linkPhone3, linkMain4, linkPhone4, humitureNum, temperatureNum);
                            humitureNumFunc();
                        }

                    } else if (devType != "humiture") {
                        $(".humitureWarningContent").hide();
                    }
                    //------------
                    //垃圾桶
                    if (devType == "trash") {
                        var trashStatus = null;
                        //31->溢出 	30—>正常	  32->高温 	33->倾倒	 34->故障
                        if (status == 31) {
                            trashStatus = 'trashBrimOver';
                        } else if (status == 34) {
                            trashStatus = 'trashFault';
                        } else if (status == 32) {
                            trashStatus = 'trashHighTemp';
                        } else if (status == 33) {
                            trashStatus = 'trashDump';
                        } else if (status == 30) {
                            trashStatus = 'trashNormal';
                        }
                        BaiDuMap.deletePoint(devCode);
                        BaiDuMap.trashAddDot(Latitude, Longitude, devCode, deviceName, address, trashStatus, linkMain1, linkPhone1, linkMain2, linkPhone2, linkMain3, linkPhone3, linkMain4, linkPhone4);
                        trashNumFunc();
                    } else if (devType == "streetLamp") {

                    } else if (devType == "camera") {

                    }
                }


            }
        }
        //客户端同步
        if (cmd == "cmd_alarmDispseSync") {
            var alarmId = strs[1];
            //移除该alarmId对应的报警弹出信息
            warningSync(alarmId);
            //coverWarningSync(alarmId);
        }

    }

    //杩炴帴鍏抽棴鐨勫洖璋冩柟娉�
    websocket.onclose = function () {
        setMessageInnerHTML("close");
    }

    //鐩戝惉绐楀彛鍏抽棴浜嬩欢锛屽綋绐楀彛鍏抽棴鏃讹紝涓诲姩鍘诲叧闂瓀ebsocket杩炴帴锛岄槻姝㈣繛鎺ヨ繕娌℃柇寮�灏卞叧闂獥鍙ｏ紝server绔細鎶涘紓甯搞��
    window.onbeforeunload = function () {
        websocket.close();
    }

    //灏嗘秷鎭樉绀哄湪缃戦〉涓�
    function setMessageInnerHTML(innerHTML) {
        // document.getElementById('message').innerHTML += innerHTML + '<br/>';
    }

    //鍏抽棴杩炴帴
    function closeWebSocket() {
        websocket.close();
    }

    //鍙戦�佹秷鎭�
    function send() {
        websocket.send(message);
    }
}

//获取当前用户信息

function getCurrentUser() {
    var userName = "";
    $.ajax({
        url: "/user/currentuser",
        type: "GET",
        async: false,
        success: function (result) {
            if (result.status == "200") {
                userName = result.data.name;
                loginNmae = result.data.loginName;
            } else {

            }
        }

    })

    $("#username span").text(userName);
}



